<?php
/**
 * Created by PhpStorm.
 * User: 14775
 * Date: 2017/9/7
 * Time: 14:19
 */

namespace Admin\Controller;


use Common\Controller\AdminbaseController;
use Common\Model\MembersModel;
use Common\ModelSQ\ERPUser;

class MemberController extends AdminbaseController
{
    protected $member_model;

    public function _initialize() {
        parent::_initialize();
        $this->member_model = new MembersModel();
    }


    public function index(){
        /**搜索条件**/
        $telephone = I('request.telephone');
        $member_name_chn = I('request.member_name_chn');
        $where = array();
        if($telephone){
            $where['telephone'] = array('like',"%$telephone%");
        }
        if($member_name_chn){
            $where['member_name_chn'] = array('like',"%$member_name_chn%");
        }


        $count=$this->member_model->where($where)->count();
        $page = $this->page($count, 10);
        $list = $this->member_model
            ->where($where)
            ->order("id DESC")
            ->limit($page->firstRow, $page->listRows)
            ->select();
        $this->assign("page", $page->show('Admin'));
        $this->assign('list',$list);
//        echo "<pre>";print_r($list);die;
        $this->display();

    }

    public function detail(){
        $erp_user = new ERPUser();
        $member_id = I('get.id');


        $member = $this->member_model->where(array('id'=>$member_id))->find();




        $this->assign('member',$member);

        $this->assign('sex_array',L('SEX'));
        $this->assign('certificate_type_array',L('CERTIFICATE_TYPE'));

        $this->display();
    }


}